﻿@model IEnumerable<FruitCake.ContactPage.Models.ContactRequestRecord>
@using FruitCake.ContactPage.ViewModels;
@using Orchard.Utility.Extensions;

<table class="items">
    <thead>
        <tr>
            <th scope="col">&nbsp;</th>
            <th scope="col">@T("Request")</th>
            <th scope="col">@T("Sender")</th>
            <th scope="col">@T("Subject")</th>
            <th scope="col">@T("State")</th>
            <th scope="col">@T("Page")</th>
        </tr>
    </thead>
    <tbody>
        @if(Model.Count() > 0)
        {
            foreach (var request in Model)
            {
            <tr>            
                <td><input type="checkbox" value="@request.Id" name="itemIds"/></td>
                <td>
                    <strong>@T("{0:00000000}", request.Id)</strong>
                    | @Html.ActionLink(T("details").ToString(), "Details", new { id = request.Id })
                    | @Html.ActionLink(T("edit").ToString(), "Edit", new { id = request.Id })
                    <br />@T("{0}", request.RequestDate)</td>
                <td>
                    <strong>@request.Mail</strong>
                    @if(!string.IsNullOrWhiteSpace(@request.Name)) {
                        <br />@request.Name
                    }                    
                </td>
                <td>
                    <strong>@request.Reason</strong>
                    @if(!string.IsNullOrWhiteSpace(@request.Name)) {
                        <br />@request.Subject
                    }
                </td>
                <td>
                    <strong>@request.StateValue.ToString()</strong>
                    @if(!string.IsNullOrWhiteSpace(request.StateUser)) {
                        @T("({0})", @request.StateUser)
                    }
                    @if(@request.RequestDate.ToString() != @request.StateDate.ToString())
                    {
                        <br />@T("({0})", @request.StateDate)    
                    }                                        
                </td>
                <td>@request.ContactPage</td>
            </tr>
            }
        } else {
            <tr>
                <td colspan="6">@T("No requests to show.")</td>
            </tr>            
        }
    </tbody>
</table>